package cn.iocoder.yudao.module.pay.dal.mysql.point;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.pay.controller.app.point.vo.AppPayPointRechargePageReqVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.point.PayPointRechargeDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.pay.controller.admin.point.vo.*;

/**
 * 会员钻石充值 Mapper
 *
 * @author Jerry
 */
@Mapper
public interface PayPointRechargeMapper extends BaseMapperX<PayPointRechargeDO> {

    default PageResult<PayPointRechargeDO> selectPage(PayPointRechargePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PayPointRechargeDO>()
                .eqIfPresent(PayPointRechargeDO::getUserId, reqVO.getUserId())
                .eqIfPresent(PayPointRechargeDO::getTotalPrice, reqVO.getTotalPrice())
                .eqIfPresent(PayPointRechargeDO::getPayPrice, reqVO.getPayPrice())
                .eqIfPresent(PayPointRechargeDO::getBonusPrice, reqVO.getBonusPrice())
                .eqIfPresent(PayPointRechargeDO::getPackageId, reqVO.getPackageId())
                .eqIfPresent(PayPointRechargeDO::getPayStatus, reqVO.getPayStatus())
                .eqIfPresent(PayPointRechargeDO::getPayOrderId, reqVO.getPayOrderId())
                .eqIfPresent(PayPointRechargeDO::getPayChannelCode, reqVO.getPayChannelCode())
                .betweenIfPresent(PayPointRechargeDO::getPayTime, reqVO.getPayTime())
                .eqIfPresent(PayPointRechargeDO::getPayRefundId, reqVO.getPayRefundId())
                .eqIfPresent(PayPointRechargeDO::getRefundTotalPrice, reqVO.getRefundTotalPrice())
                .eqIfPresent(PayPointRechargeDO::getRefundPayPrice, reqVO.getRefundPayPrice())
                .eqIfPresent(PayPointRechargeDO::getRefundBonusPrice, reqVO.getRefundBonusPrice())
                .betweenIfPresent(PayPointRechargeDO::getRefundTime, reqVO.getRefundTime())
                .eqIfPresent(PayPointRechargeDO::getRefundStatus, reqVO.getRefundStatus())
                .betweenIfPresent(PayPointRechargeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PayPointRechargeDO::getId));
    }

    default PageResult<PayPointRechargeDO> selectPage(AppPayPointRechargePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PayPointRechargeDO>()
                .eqIfPresent(PayPointRechargeDO::getUserId, reqVO.getUserId())
                .eqIfPresent(PayPointRechargeDO::getTotalPrice, reqVO.getTotalPrice())
                .eqIfPresent(PayPointRechargeDO::getPayPrice, reqVO.getPayPrice())
                .eqIfPresent(PayPointRechargeDO::getBonusPrice, reqVO.getBonusPrice())
                .eqIfPresent(PayPointRechargeDO::getPackageId, reqVO.getPackageId())
                .eqIfPresent(PayPointRechargeDO::getPayStatus, reqVO.getPayStatus())
                .eqIfPresent(PayPointRechargeDO::getPayOrderId, reqVO.getPayOrderId())
                .eqIfPresent(PayPointRechargeDO::getPayChannelCode, reqVO.getPayChannelCode())
                .betweenIfPresent(PayPointRechargeDO::getPayTime, reqVO.getPayTime())
                .eqIfPresent(PayPointRechargeDO::getPayRefundId, reqVO.getPayRefundId())
                .eqIfPresent(PayPointRechargeDO::getRefundTotalPrice, reqVO.getRefundTotalPrice())
                .eqIfPresent(PayPointRechargeDO::getRefundPayPrice, reqVO.getRefundPayPrice())
                .eqIfPresent(PayPointRechargeDO::getRefundBonusPrice, reqVO.getRefundBonusPrice())
                .betweenIfPresent(PayPointRechargeDO::getRefundTime, reqVO.getRefundTime())
                .eqIfPresent(PayPointRechargeDO::getRefundStatus, reqVO.getRefundStatus())
                .betweenIfPresent(PayPointRechargeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PayPointRechargeDO::getId));
    }

    default PageResult<PayPointRechargeDO> selectPage(PageParam pageReqVO, Long userId, Boolean payStatus) {
        return selectPage(pageReqVO, new LambdaQueryWrapperX<PayPointRechargeDO>()
                .eq(PayPointRechargeDO::getUserId, userId)
                .eq(PayPointRechargeDO::getPayStatus, payStatus)
                .orderByDesc(PayPointRechargeDO::getId));
    }

    default int updateByIdAndPaid(Long id, boolean wherePayStatus, PayPointRechargeDO updateObj) {
        return update(updateObj, new LambdaQueryWrapperX<PayPointRechargeDO>()
                .eq(PayPointRechargeDO::getId, id).eq(PayPointRechargeDO::getPayStatus, wherePayStatus));
    }
}